<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
			
		<title>Toma de Decisiones</title>
        <meta name="viewport" content="width=device-width; initial-scale=1.0" />
		<link rel="stylesheet" href="css/jquery.mobile-1.3.2.css" />
		<link rel="stylesheet" href="css/custom.css" />
		<link rel="stylesheet" href="css/app.css" />
		<link rel="stylesheet" href="css/fonts.css" />
		<script type="text/javascript" charset="utf-8" src="js/cordova-2.9.0.js"></script>
		<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
	    <script type="text/javascript" src="js/jquery.mobile-1.3.1.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="js/library.js"></script>
		<script type="text/javascript" charset="utf-8" src="js/common.js"></script>
        <script type="text/javascript" charset="utf-8" src="js/localize.js"></script>
        <script type="text/javascript" charset="utf-8" src="js/fileopener.js"></script>
		<script type="text/javascript" charset="utf-8" src="js/checkNetwork.js"></script>
    	<script type="text/javascript" charset="utf-8">
	  	
		 	var parameter = '';
		 	
		 	$(document).on('pagebeforeshow', "#sendEmail", function (event, data) {
		 		checkNetwork();
		 		parameter = getParameter('id');
	 	     	$("#errorMsg").html("");
	 	     	document.addEventListener("deviceready", onDeviceReady, true); 
		 	});
		 	
		 	function onDeviceReady() {
		        excecuteLocalization(["global", "sendEmail"]);
		    }
		 	
		 	function backToDecision(){
		 		var url = "decisions/buy_" + parameter + ".html";
		 		if(parameter!=''){
		 			url = "decisions/buy_" + parameter + ".html";
		 		} else{
		 			url = "main.html";
		 		}
		 		window.location.href = url;
		 	}
		 	
		 	function sendEmail(){
				
		 		var email_address = $("#email_address").val();
		 		$("#errorMsg").html("");
		 		
		 	  	var url = "http://www.xeliom.com/TD/sendEmail.php"

			 	$.mobile.loadingMessage = "Procesando...";
			 	$.mobile.loading('show');
		 		
			 	$.getJSON(url, { email_address: email_address, type: parameter }).done(function(data) {
		 			//alert("Message: " + data.message);
		 			if(data.status == "ok"){
		 			 	//alert("Email enviado a " + data.email);
		 			 	$("#errorMsg").html("Email enviado a " + data.email);
		 			 	//backToDecision();
		 			}else{
		 			 	//alert("No se pudo enviar email");
		 			 	$("#errorMsg").html("No se pudo enviar el email");
		 			}
		 			$.mobile.loading('hide');
		 		});
		 	}
		 	
		 </script>
	</head>
<body style="text-align: center;">

<div  data-role="page" style="display:none;" id="sendEmail"> 
	
	<div data-role="panel" data-position="right" data-position-fixed="false" data-display="overlay" id="menu-panel" data-theme="a">

		<ul data-role="listview" data-theme="a" data-divider-theme="a" style="margin-top:-16px;" class="nav-search">
			<li data-icon="delete" style="background-color:#111;">
				<a href="#header" data-rel="close"><span data-translate="localize">global.close_menu</span></a>
			</li>
			<li>
				<a href="javascript:backToHome();"><span data-translate="localize">global.go_home</span></a>
			</li>
			<li>
				<a href="javascript:window.location.href='settings.html'"><span data-translate="localize">global.settings</span></a>
			</li>
			<li>
				<a href="javascript:exitAPP();"><span data-translate="localize">global.exit</span></a>
			</li>
		</ul>
		<span data-translate="localize" id="confirm_msgTag" style="display:none;">global.confirm_msg</span>
		<!-- panel content goes here -->
	</div><!-- /panel -->

	<div  data-role="header" id="header"  data-position="fixed">
		<img border="0" src="images/img-logo.png" alt="Logo" height="35" width="35" style="float:left; display:inline"/>
		<a href="javascript:openMenu();" data-icon="gear" class="ui-btn-right" id="openMenuButton"><span data-translate="localize">global.menu</span></a>
	</div>     
	<div  data-role="content">
		<table style="width: 100%">
			<tr><td></td></tr>
			<tr>
				<td>
					<br>
					<div id="pageTitle"></div> 
				</td>
			</tr>
			<tr>
				<td>			
					&nbsp;
				</td>
			</tr>
			<tr>
				<td>		
					<p>
						<span data-translate="localize">write_email</span>:<br><br>
						<input type="text" type="email" id='email_address' name='email_address'>
						<div class="errorMsg" id="errorMsg"></div>
					</p>
					<p>
						<button onclick="sendEmail();" data-theme="f"><span data-translate="localize">request_email</span></button>
					</p>
					<p>
						<span data-translate="localize">p_1</span>	
					</p>
					<p>
						<span data-translate="localize">p_2</span>
					</p>
					<p>
						<span data-translate="localize">p_3</span>
					</p>
				</td>
			</tr>
			<tr>
				<td>			
					&nbsp;
				</td>
			</tr>
			<tr>
				<td>
					<button onclick="backToDecision();"><span data-translate="localize">global.back</span></button>	
				</td>
			</tr>
		</table>
	</div> 
	<!-- 
	<div  data-role="footer" data-position="fixed">
		<button class="button-main-small" onclick="exitAPP();"><span data-translate="localize">global.exit</span></button>
	</div>
	-->
</div>
</body>
</html>